using System;
using System.Collections.Generic;
using System.Text;

namespace Weazel.Toad.Application.Actions
{
    public class InsertSimplifiedOpbMasterIpBlock
      : ActionBase
    {
        private static string description =
            "ipblock opb_slave (                     \n" +
            "   in 	m_request       : ns(1);         \n" +
            "   in 	m_select	    : ns(1);         \n" +
            "   in 	m_rnw           : ns(1);         \n" +
            "   in 	m_dbus		    : ns(32);        \n" +
            "   in 	m_abus		    : ns(32);        \n" +
            "   out opb_grant	    : ns(1);         \n" +
            "   out opb_xfer_ack    : ns(1);         \n" +
            "   out opb_dbus        : ns(32)         \n" +
            ") {                                     \n" +
            "   iptype \"opbmaster\";                \n" +            
            "}\n";

        public InsertSimplifiedOpbMasterIpBlock()
        {
            Enabled = false;

            Application.Instance.SelectedItemChanged +=
              new EventHandler<SelectedItemChangedEventArgs>(Instance_SelectedItemChanged);
        }

        public override void Execute(object sender, EventArgs e)
        {
            if (Application.Instance.SelectedItem is Items.GezelTextFile)
            {

                Items.GezelTextFile file =
                      Application.Instance.SelectedItem as Items.GezelTextFile;

                file.TextEditor.TextAreaControl.TextArea.InsertString(description);
            }
        }

        void Instance_SelectedItemChanged(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem is Items.GezelTextFile)
            {
                Enabled = true;
            }
            else
            {
                Enabled = false;
            }
        }
    }
}
